package gagak.framework.web.annonation;

import java.util.HashMap;
import java.util.Map;

/*
 * @program: ce
 * @description:
 * @author: houhong
 * @create: 2022-11-23 21:21
 */
public enum HttpMethod {

    GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;


    private static final Map<String, HttpMethod> mappings = new HashMap<String, HttpMethod>(16);


    static {
        for (HttpMethod httpMethod : values()) {
            mappings.put(httpMethod.name(), httpMethod);
        }
    }


    public static HttpMethod resolve(String method) {
        return (method != null ? mappings.get(method) : null);
    }


    public boolean matches(String method) {
        return (this == resolve(method));
    }
}